package icms.service;

import icms.ORM.MySessionFactroy;
import icms.ORM.UserInfo;
import java.util.ArrayList;
import java.util.List;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;

public class LoginService{
	public UserInfo checkAdminLogin(String userName,String userPwd){
		UserInfo user=new UserInfo();
		List resultList=new ArrayList();
		Session session=MySessionFactroy.getSession();
		Transaction tx=session.beginTransaction();
		String hql="from UserInfo as u where u.userName=:userName and u.userPwd=:userPwd and u.userClass>1";
		Query query=session.createQuery(hql);
		query.setString("userName", userName);
		query.setString("userPwd", userPwd);
		resultList=query.list();
		tx.commit();
		
		if(resultList.isEmpty()) return null;
		else return (UserInfo)resultList.get(0);
	}
}
